package com.nulldev.util.string;

import java.util.LinkedList;

public class StandardString {

	private final static LinkedList<Replacement> REPLACEMENTS = new LinkedList<Replacement>();
	public static class Replacement {
		private final char[] toReplace;
		private final char replacement;
		
		public Replacement(final char[] toReplace, final char replacement) {
			this.toReplace = toReplace;
			this.replacement = replacement;
		}
		
		public char[] getReplace() {
			return this.toReplace;
		}
		
		public char getReplacement() {
			return this.replacement;
		}
	}
	
	static {
		if (REPLACEMENTS.isEmpty()) {
			REPLACEMENTS.add(new Replacement(new char[] {
					'\u00c0', '\u00c1', '\u00c2', '\u00c3', '\u00c4', '\u00c5', '\u00c6'
			}, 'A'));
			REPLACEMENTS.add(new Replacement(new char[] {
				'\u0179', '\u017b', '\u017d'	
			}, 'Z'));
			REPLACEMENTS.add(new Replacement(new char[] {
					'\u017a','\u017c', '\u017e'
			}, 'z'));
		}
	}
	
	public static String replace(final String input) {
		String out = input;
		for (final Replacement r : (LinkedList<Replacement>) REPLACEMENTS.clone()) {
			for (final char c : r.getReplace()) {
				out = out.replace(c, r.getReplacement());
			}
		}
		return out;
	}
}
